<!DOCTYPE html>
<html lang="en">
<head>
<!-- Powered by Shinobi, http://shinobi.video -->
<%- include('blocks/header-title'); %>
<%
    if(config.baseURL)window.libURL = config.baseURL;
    if(!window.libURL)window.libURL = originalURL;
 %>
<%- include('blocks/header-meta'); %>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="<%-window.libURL%>assets/vendor/bootstrap5/css/bootstrap.min.css">
<link rel="stylesheet" href="<%-window.libURL%>assets/css/bootstrap5-theme.css">
<link rel="stylesheet" href="<%-window.libURL%>assets/vendor/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="<%-window.libURL%>assets/css/login.css">
<link rel="stylesheet" href="<%-window.libURL%>assets/css/gradients.css">
<link rel="stylesheet" href="<%-window.libURL%>assets/css/bs5.darktheme.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<%- include('blocks/header-favicon'); %>
<script src="<%-window.libURL%>assets/vendor/js/jquery.min.js"></script>
<script src="<%-window.libURL%>assets/vendor/js/jquery-ui.min.js"></script>
<script src="<%-window.libURL%>assets/vendor/js/jquery.serialize.js"></script>
<meta name="google-signin-client_id" content="<%- config.appIdGoogleSignIn %>">
</head>
<% cleanLang = function(string){
    if(!string){string=''}
    return string.replace(/'/g,"\\'")
}%>
<% if(screen){screen=screen.toLowerCase()} %>
<body>
<div id="page-contents" class="display-table full-height">
    <div class="shinobi-bg-shade bg-gradient-<%- screen === 'super' ? 'green' : 'blue' %>">
    	<div class="d-flex flex-row full-height">
			<div class="col-0 col-lg-8" style="background-image:url(<%- config.loginScreenBackground %>);<%- config.loginScreenBackgroundCss ? config.loginScreenBackgroundCss : 'background-size: cover;opacity: 0.2;' %>">

            </div>
			<div class="col-12 col-lg-4 vertical-center" style="background:rgba(0,0,0,0.8)">
                <div style="flex:1" class="p-4">
                    <!-- Logo/Header -->
                    <div>
                        <% if(config.showLoginCardHeader === true){
                            var logoImageLink
                            if(config.logoLocation76x76.indexOf('//') === -1){
                                logoImageLink = window.libURL + config.logoLocation76x76
                            }else{
                                logoImageLink = config.logoLocation76x76
                            }
                            %>
                            <div class="text-center p-2">
                                <a href="<%- config.logoLocation76x76Link %>" target="_blank">
                                    <img src="<%- logoImageLink %>" style="<%- config.logoLocation76x76Style %>">
                                </a>
                            </div>
                        <% } %>
                    </div>
                    <!-- Logo/Header END -->
                    <!-- Card -->
    				<div class="text-white">
                        <div class="text-center">
                            <h4 class="mt-3 mb-2 text-white" style="font-weight:normal"><%- lang.Welcome %></h4>
                        </div>
    					<div class="card-body">
    						<div class="row dark">
								<form id="login-form" method="post" style="display: block;margin:0">
                                    <input type="hidden" name="machineID" id="machineID" value="">
                                    <% var message,timeLeft;if(message){ %>
                                        <div class="form-group text-center monospace" id ="login-message">
                                            <%= message %>
    									</div>
                                    <% } %>
									<div class="form-group">
                                        <label><%- lang['Email'] %></label>
										<input type="text" name="mail" id="email" tabindex="1" autofocus class="form-control wide-text" placeholder="<%- lang.Email %>" value="">
									</div>
									<div class="form-group">
                                        <label><%- lang['Password'] %></label>
										<input type="password" name="pass" id="pass" tabindex="2" class="form-control wide-text" placeholder="<%- lang.Password %>">
									</div>
									<div class="form-group f_i_input f_i_ldap" style="display:none">
                                        <label><%- lang['Group Key'] %></label>
										<input name="key" id="key" tabindex="2" class="form-control wide-text" placeholder="Group Key">
									</div>
                                    <% if(config.showLoginSelector === true){ %>
    									<div class="form-group f_i_input f_i_">
                                            <label><%- lang['Landing Page'] %></label>
        									<div class="row">
                                                <div class="col-md-12">
                                                    <select class="form-control wide-text" name="function">
                                                        <% switch(screen){
                                                            case'super': %>
                                                        <option value="super"><%- lang.Superuser %></option>
                                                        <% break;
                                                            case'admin': %>
                                                        <option value="admin"><%- lang.Admin %></option>
                                                        <% break;
                                                            default: %>
                                                        <option value="dash" selected><%- lang.Dashboard %></option>
                                                        <option value="streamer"><%- lang.Streamer %></option>
                                                        <option value="cam"><%- lang.Dashcam %> (<%- lang.Streamer %> v2)</option>
                                                        <% break;
                                                        } %>
                                                    </select>
                                                </div>
        									</div>
    									</div>
                                    <% }else{ %>
                                        <select class="form-control wide-text" name="function" style="display:none">
                                            <% switch(screen){
                                                case'super': %>
                                            <option value="super"><%- lang.Superuser %></option>
                                            <% break;
                                                case'admin': %>
                                            <option value="admin"><%- lang.Admin %></option>
                                            <% break;
                                                default: %>
                                            <option value="dash" selected><%- lang.Dashboard %></option>
                                            <% break;
                                            } %>
                                        </select>
                                    <% } %>
                                    <div class="form-group" <%- config.showLoginTypeSelector === true ? '' : 'style="display:none"' %>>
                                        <label><%- lang['Authenticate'] %></label>
                                        <select class="form-control wide-text" name="alternateLogin" selector="f_i">
                                            <option value="" selected><%- lang.Default %></option>
                                            <% if(config.allowGoogleSignOn){ %>
                                                <option value="google">Google</option>
                                            <% } %>
                                            <option value="ldap"><%- lang.LDAP %></option>
                                        </select>
                                        <input style="display:none" name="alternateLoginToken" class="form-control wide-text" placeholder="Group Key">
                                    </div>
                                    <div class="form-group">
                                        <label class="mb-0">
                                            <input class="mt-1 mr-1" type="checkbox" id="remember_me" value="1" name="remember">
                                            <span class="text-white"><%- lang['Remember Me'] %></span>
                                        </label>
                                    </div>
									<div class="form-group mt-4">
                                        <button type="submit" name="login-submit" id="login-submit" tabindex="4" class="btn btn-success btn-block wide-text" style="color:#FFF"><%- lang.Login %></button>
									</div>
                                    <% if(config.allowGoogleSignOn){ %>
    									<div class="form-group text-center">
                                            <div class="g-signin2" data-onsuccess="onGoogleSignIn" style="display: inline-block;"></div>
    									</div>
                                    <% } %>
								</form>
    						</div>
    					</div>
    				</div>
                    <!-- Card END -->
                    <div class="my-5"></div>
                    <div class="form-group mb-0 text-center">
                        <% config.socialLinks.forEach((item) => { %>
                            <a class="mr-2 social-link btn btn-primary <%- item.color || 'bg-none text-white' %>" target="_blank" href="<%- item.href %>">
                                <div class="d-flex flex-row full-height">
                                    <div class="vertical-center full-height" style="flex: 1">
                                        <i class="fa fa-<%- item.icon %>"></i>
                                    </div>
                                </div>
                            </a>
                        <% }) %>
                    </div>
                    <!-- Powered By Shinobi -->
                    <div class="mt-4"></div>
                    <div class="text-center text-white monospace mt-2">
                        <small>
                            <% if(config.showPoweredByShinobi){ %>
                                <p><%- config.poweredByShinobi %></p>
                            <% }else{ %>
                                <!-- <%- config.poweredByShinobi %> -->
                            <% } %>
                        </small>
                    </div>
                    <!-- Powered By Shinobi END -->
				</div>
			</div>
		</div>
    </div>
</div>
</body>
<script>
    var googleSignIn = false;
    <% var failedLogin;if(failedLogin===true){ %>
        localStorage.removeItem('ShinobiLogin_'+location.host)
    <% } %>
</script>
<script src="<%-window.libURL%>assets/js/bs5.login.js"></script>
<% if(config.allowGoogleSignOn){ %>
    <script src="https://apis.google.com/js/platform.js" async defer></script>
    <script>
        function onGoogleSignIn(googleUser) {
            var id_token = googleUser.getAuthResponse().id_token;
            loginForm.find('[name="mail"],[name="pass"],[name="alternateLogin"],.g-signin2').hide()
            loginForm.find('[name="alternateLogin"]').val('google')
            loginForm.find('[name="alternateLoginToken"]').val(id_token)
            googleSignIn = true
            loginForm.submit()
        }
        function googleSignOut() {
          var auth2 = gapi.auth2.getAuthInstance();
          auth2.signOut().then(function () {
            console.log('Google Signed out.');
          });
        }
    </script>
<% } %>
</html>
